<?php
	class support{
		public $id;
		public $HoTen;
		public $Yahoo;
		public $Skype;
		public $DienThoai;
		public $TrangThai;
		public function getSupportByWhere($where,$order){
			
			$db = new db();
			$db->getInstance();
			$sql = "select * from tblsupport";
			if($where != '') $sql .= ' where ' . $where;
			if($order != '') $sql .= ' order by ' . $order; //echo $sql; die;
			$rs = mysql_query($sql);
			if(mysql_num_rows($rs)>0){
				while($rc = mysql_fetch_object($rs)){
					$lstHangSanXuat[] = $rc;	
				}
				return $lstHangSanXuat;
			}
			else return null;
		}
		
		public function getSupportById($id){
			$db = new db();
			$db->getInstance();
			$sql = "Select * from tblsupport where id = " . $id;
			$rs = mysql_query($sql);
			$rc = mysql_fetch_object($rs);
			return $rc;
		}
		
		
		public function insert($support){
			$db = new db();
			$db->getInstance();
			$sql = "Insert tblsupport(HoTen,Yahoo,Skype,DienThoai,TrangThai) values('".$support->HoTen."','".$support->Yahoo."','".$support->Skype."','".$support->DienThoai."',".$support->TrangThai.")"; //echo $sql; die;
			$rs = mysql_query($sql);
			if($rs) return true;
			else return false;
		}
		
		public function update($support){
			$db = new db();
			$db->getInstance();
			$sql = "Update tblsupport set HoTen='".$support->HoTen."',Yahoo='".$support->Yahoo."',Skype='".$support->Skype."',DienThoai='".$support->DienThoai."',TrangThai=".$support->TrangThai." where id =".$support->id; //echo $sql; die;
			$rs = mysql_query($sql);
			if($rs) return true;
			else return false;
		}
		
		public function delete($id){
			$db = new db();
			$db->getInstance();
			$sql = "delete from tblsupport where id=".$id; //echo $sql; die;
			$rs = mysql_query($sql);
			if($rs) return true;
			else return false;
		}
	}
?>